package com.itheima.service.impl;

import com.itheima.dao.MoviesDao;
import com.itheima.domain.Movies;
import com.itheima.domain.MoviesExample;
import com.itheima.service.MoviesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MoviesServiceImpl implements MoviesService {

    @Autowired
    private MoviesDao moviesDao;

    @Override
    public List<Movies> findList(MoviesExample moviesExample) {
        return moviesDao.selectByExample(moviesExample);
    }

    @Override
    public void insert(Movies movies) {
        moviesDao.insertSelective(movies);
    }

    @Override
    public Movies findById(Integer id) {
        return moviesDao.selectByPrimaryKey(id);
    }

    @Override
    public void update(Movies movies) {
        moviesDao.updateByPrimaryKeySelective(movies);
    }

    @Override
    public void deleteById(Integer id) {
        moviesDao.deleteByPrimaryKey(id);
    }

    @Override
    public void deleteByIds(Integer[] ids) {
        for (Integer id : ids) {
            moviesDao.deleteByPrimaryKey(id);
        }
    }
}
